package center.leon.zoomvcsentinel.monkey.controller;

import center.leon.zoocommon.common.Response;
import center.leon.zoomvcsentinel.monkey.service.MonkeyServiceApi;
import center.leon.zoomvcsentinel.monkey.vo.Monkey;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.EnvironmentAware;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author : Leon on XXM Mac
 * @since : create in 2024/8/20 14:24
 */
@Slf4j
@RestController
@RequestMapping(value = "/monkey")
public class MonkeyController {

    @Value("${server.port}")
    private Integer port;

    @Resource
    private MonkeyServiceApi monkeyServiceApi;

    @GetMapping(value = "/hello")
    public Response<Monkey> helloWorld(){
        return Response.success(new Monkey().setColor("hello").setName("leon : " + port));
    }

    @GetMapping(value = "/hi")
    public Response<Monkey> hiWorld(){
        log.info("monkey hi : {}", port);
        return Response.success(new Monkey().setColor("hi").setName("leon : " + port));
    }

    @GetMapping(value = "/hei")
    public Response<Monkey> heiWorld(){
        String hei = monkeyServiceApi.helloWorld("hei");
        return Response.success(new Monkey().setColor(hei).setName("leon : " + port));
    }
}
